class Solution {
    public String minWindow(String s, String t) {
        char[] s1=s.toCharArray();
        char[] t1=t.toCharArray();
        int[] ret=new int[2];

        int len=99999999;
        int[] arr=new int[100];
        int[] arr1=new int[100];
        int count=0;
        for(char a:t1) arr[a-'A']++;
        int left=0,right=0;

        while(right<s1.length){
            char c=s1[right];
            arr1[c-'A']++;
            if(arr1[c-'A']<=arr[c-'A']) count++;


            while(count==t1.length){
                if(len>right-left+1){
                    len=right-left+1;
                    ret[0]=left;
                    ret[1]=right;
                }

                c=s1[left++];

                if(arr1[c-'A']<=arr[c-'A']) count--;
                arr1[c-'A']--;

            }

            right++;
        }
        return len==99999999?"":s.substring(ret[0],ret[1]+1);
    }
}